package basicCompiler;

import java.util.regex.Pattern;

public class NodeFactory {
	
	public static Node createNode(String exp){
		
		if (Pattern.matches("[a-z]", exp))
			return new Variabile(exp);
		
		if (Pattern.matches( "[0-9]+", exp))
			return new IntegerValue (exp);
		if ((Pattern.matches( "true", exp)) || (Pattern.matches( "false", exp)))
			return new BooleanValue( exp);
		
		if (Pattern.matches( "=", exp))
			return new EqualsOperator(exp);
		if (Pattern.matches( "\\+", exp))
			return new OrOperator(exp);
		if (Pattern.matches( "\\*", exp))
			return new AndOperator(exp);
	
		
		throw new IllegalArgumentException("Expresion pattern not recognized!");
	}
}
